package com.modifiertech.lineage.network;

import net.minecraftforge.fml.common.network.NetworkRegistry;
import net.minecraftforge.fml.common.network.simpleimpl.SimpleNetworkWrapper;
import net.minecraftforge.fml.relauncher.Side;

//轮论述一个handler 若干个message 就可以,不需要多个 handler
public class NetworkHandler {
    public static SimpleNetworkWrapper INSTANCE;
    public static int ID;
    public static void registerMessages(String channelName){
        INSTANCE = NetworkRegistry.INSTANCE.
                newSimpleChannel(channelName);
        registerMessages();
    }
    private static void registerMessages(){
        //注册同步用户数据消息
        //玩家数据同步.服务端同步至客户端
        INSTANCE.registerMessage(MessageDataSync.class, MessageDataSync.class, ID++, Side.CLIENT);
        //属性更新.客户端同步至服务端
        INSTANCE.registerMessage(MessageAttributeModify.class, MessageAttributeModify.class, ID++, Side.SERVER);
        //技能更新.客户端同步至服务端
        INSTANCE.registerMessage(MessageSkillModify.class, MessageSkillModify.class, ID++, Side.SERVER);
        //动画呼出.客户端同步至服务端
        INSTANCE.registerMessage(MessageAnimateCall.class, MessageAnimateCall.class, ID++, Side.SERVER);
        //客户端渲染消息:技能 JumpSplash.服务端同步至客户端
        INSTANCE.registerMessage(MessageClientSkillJumpSplash.class,MessageClientSkillJumpSplash.class,ID++,Side.CLIENT);
        //技能CD同步.服务端同步至客户端
        INSTANCE.registerMessage(MessageClientSkillCD.class,MessageClientSkillCD.class,ID++,Side.CLIENT);
        //技能持有状态同步.服务端同步至客户端
        INSTANCE.registerMessage(MessageClientSkillHandingState.class,MessageClientSkillHandingState.class,ID++,Side.CLIENT);
        //技能范围状态同步.服务端同步至客户端
        INSTANCE.registerMessage(MessageClientSkillRange.class,MessageClientSkillRange.class,ID++,Side.CLIENT);
        //技能范围状态同步.客户端同步至服务端
        INSTANCE.registerMessage(MessageServerSkillRange.class,MessageServerSkillRange.class,ID++,Side.SERVER);
        //信息呼出.服务端同步至客户端
        INSTANCE.registerMessage(MessageClientSay.class,MessageClientSay.class,ID++,Side.CLIENT);
    }
}
